# include "myHeader.h"

void moveHare(char *path, char **Hare){
	//Declaring a variable to return after calling the rand function
	int random1;

	//This will help to see whether the hare is sleeping or moving 
	//in this turn
	random1 = rand()%2;

	//Not really needed but this is to get 1/2 instead of 0/1
	random1++;

	//If random1 is 1 and not 2 turtoise is not sleeping so its running
	if(random1 == 1){

		//This is to see how many places the turtoise will jump
		random1 = rand()%8;

		//Since we need turtoise to move 1-8 spots instead of 0-7 which
		//is what the previous statement will do we are incrementing by 1
		random1++;

		//This while loop is used to check if there is anything other than 
		//a space in the place the hare wants to move if there is, then 
		//this loop will cause hare to move to the most previous space that 
		//is farther then where the hare is currently.

		//loop runs only if place hare wants to move is  in front not in the back
		while(*Hare < (*Hare+random1)){
			
			//checking if space is free.
			if(*((*Hare) + random1) == ' '){
				*Hare += random1;
				break;
			}
			//If space not free then going to previous space and then rechecking
			else
				random1--;
		}
	}
}